/*************************************************************************
	> File Name: task.hpp
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/10/02 18:25
 ************************************************************************/

#pragma once

#include <iostream>
#include <string>
#include <functional>
#include "log.hpp"

using func_t = std::function<void (int, const std::string &, const uint16_t &, const std::string &)>;

class Task
{
public:
    Task ()
    {}

    Task(int sock, const std::string ip, const uint16_t port, func_t func):_sock(sock), _ip(ip), _port(port), _func(func)
    {}

    void operator ()(const std::string &name)
    {
        _func(_sock, _ip, _port, name);
    }

private:
    std::string _ip;
    uint16_t _port;
    func_t _func;
    int _sock;
};
